<template>
    <div class="man-list" style="border: aqua solid 3px">
        <div>用户名:{{username}}</div>

        <div class="table">
            <div >
                <span class="name">名称</span>
                <span class="price">价格</span>
                <span class="num">数量</span>
                <span class="caozuo">总价</span>
                <span class="name">操作</span>
            </div>
            <div v-for="(i,index) in carList" :key="index">
                <span class="name">{{i.name}}</span>
                <span class="price">{{i.price}}</span>
                <span class="num">{{i.num}}</span>
                <span class="caozuo">{{i.price*i.num}}</span>
                <span class="name">
                    <button @click="jia(index)">+</button>&nbsp;<button @click="jian(index)">-</button>
                </span>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'payCar',
        data(){
            return {
                username:this.$store.state.payCar.username,
                changeItem:{
                    name:'',
                    price:0,
                    num:0,
                    newPrice:0,
                    index:0
                },
                isChangePrice:false,
            }
        },
        props:{
            name:String,
            id:Number,
            num:Number
        },
        methods:{
            jia(val){
                this.$store.commit('payCar/addNumCar',val)
            },
            jian(val){
                this.$store.commit('payCar/dropNumCar',val)
            }
        },
        computed:{
            carList(){
                return this.$store.state.payCar.carList
            },


        },

        mounted(){
            console.log(
                this.$route,this.$router
            )
        }
    }
</script>

<style>


</style>
